Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@otplib/preset-default

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@otplib/preset-default

basic preset for otplib

  • 12.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @otplib/preset-default?

@otplib/preset-default is a preset configuration for the otplib (One Time Password Library) that provides default settings for generating and validating one-time passwords (OTPs) using TOTP (Time-based One-Time Password) and HOTP (HMAC-based One-Time Password) algorithms.

What are @otplib/preset-default's main functionalities?

Generate TOTP

This feature allows you to generate a Time-based One-Time Password (TOTP) using a secret key. The generated token is time-sensitive and changes periodically.

const otplib = require('@otplib/preset-default');
const secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD';
const token = otplib.authenticator.generate(secret);
console.log(token);

Validate TOTP

This feature allows you to validate a given TOTP against a secret key. It returns a boolean indicating whether the token is valid.

const otplib = require('@otplib/preset-default');
const secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD';
const token = '123456';
const isValid = otplib.authenticator.check(token, secret);
console.log(isValid);

Generate HOTP

This feature allows you to generate an HMAC-based One-Time Password (HOTP) using a secret key and a counter. The generated token is counter-based and changes with each increment of the counter.

const otplib = require('@otplib/preset-default');
const secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD';
const counter = 1;
const token = otplib.hotp.generate(secret, counter);
console.log(token);

Validate HOTP

This feature allows you to validate a given HOTP against a secret key and a counter. It returns a boolean indicating whether the token is valid.

const otplib = require('@otplib/preset-default');
const secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD';
const token = '123456';
const counter = 1;
const isValid = otplib.hotp.check(token, secret, counter);
console.log(isValid);

Other packages similar to @otplib/preset-default

Keywords

FAQs

Package last updated on 24 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc